package com.aaa.service.impl;

import com.aaa.dao.UserDao;
import com.aaa.dao.impl.UserDaoImpl;
import com.aaa.service.UserService;
import com.aaa.utils.MyTools;

import java.util.List;
import java.util.Map;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/8/9 9:19
 * @description：
 * @modified By：
 * @version:
 */
public class UserServiceImpl  implements UserService {
    UserDao userDao = new UserDaoImpl();
    @Override
    public List<Map<String, Object>> queryAll(Map map) {
        return userDao.queryAll(map);
    }

    @Override
    public Long queryCount(Map map) {
        return userDao.queryCount(map);
    }
    /**
     * @create by: Teacher陈（86521760@qq.com）
     * @description: 处理用户的基本信息，密码加盐加密
     * @create time: 2022/8/10 11:02
     * @param map
     * @return boolean
     */
    @Override
    public boolean saveUser(Map map) {
        String password = map.get("password")+"";
        //密码加密，并返回  盐值和密文密码
        Map<String, String> stringMap = MyTools.makePasswordSalt(password);
        map.put("salt",stringMap.get("salt"));
        //替换原有的明文密码
        map.put("password",stringMap.get("password"));
        return userDao.saveUser(map);
    }

    @Override
    public boolean deleteUser(Map map) {
        return userDao.deleteUser(map);
    }

    @Override
    public List<Map<String, Object>> queryUserByName(Map map) {
        return userDao.queryUserByName(map);
    }
}
